package com.tgy.mapper;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tgy.entity.Blog;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/***
 * @ClassName: ServiceTest
 * @Description:
 * @Auther: tanggy3
 * @Date: 18:10 2022/8/5
 * @version : V1.0
 */
@Service
public class ServiceTest {
    private final BlogMapper blogMapper;

    public ServiceTest(BlogMapper blogMapper) {
        this.blogMapper = blogMapper;
    }
    public PageInfo<Blog> test(){
        Page<Object> objects = PageHelper.startPage(1, 3);

        List<Blog> all = this.blogMapper.getAll();
        List<Blog> collect = all.stream().peek((bean) -> {
            System.out.println("数量为"+bean.getViews());
        }).collect(Collectors.toList());
        PageInfo<Blog> blogPageInfo = new PageInfo<>(collect);
        List<Blog> all1 = this.blogMapper.findAll();
        long total = objects.getTotal();
        System.out.println(objects.getTotal());
        System.out.println(total);
        return blogPageInfo;
    }
}
